// 延期柱状图
export function postponenum(data) {
    let chart = data.chart
    let xiadanarr = []
    let rukuarr = []
    for (let index = 0; index < chart.length; index++) {
        xiadanarr.push(chart[index].xiadan)
        rukuarr.push(chart[index].ruku)
    }
    return {
        title: {
            text: '',
            subtext: ''
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: ['下单数', '入库数']
        },
        toolbox: {
            show: true,
            feature: {
                dataView: { show: true, readOnly: false },
                magicType: { show: true, type: ['line', 'bar'] },
                restore: { show: true },
                saveAsImage: { show: true }
            }
        },
        calculable: true,
        xAxis: [
            {
                type: 'category',
                // prettier-ignore
                data: data.week
            }
        ],
        yAxis: [
            {
                type: 'value'
            }
        ],
        series: [
            {
                name: '下单数',
                type: 'bar',
                data: xiadanarr,
                markPoint: {
                    data: [
                        { type: 'max', name: 'Max' },
                        { type: 'min', name: 'Min' }
                    ]
                },
                markLine: {
                    data: [{ type: 'average', name: 'Avg' }]
                }
            },
            {
                name: '入库数',
                type: 'bar',
                data: rukuarr,
                markLine: {
                    data: [{ type: 'average', name: 'Avg' }]
                }
            }
        ]
    }

}


// 延期柱状图对比
export function postponenumall(date, data) {
    let listone = data[0].list
    let datatitle = []
    for (let index = 0; index < listone.length; index++) {
        datatitle.push(listone[index].factory_name)
    }
    let series = []
    for (let index = 0; index < data.length; index++) {
        let list = data[index].list
        for (let idx = 0; idx < list.length; idx++) {
            if (index == 0) {
                let obj = {
                    name: list[idx].factory_name,
                    type: 'bar',
                    data: [list[idx].num],
                    markPoint: {
                        data: [
                            { type: 'max', name: 'Max' },
                            { type: 'min', name: 'Min' }
                        ]
                    },
                    markLine: {
                        data: [{ type: 'average', name: 'Avg' }]
                    }
                }
                series.push(obj)
            } else {
                series[idx].data.push(list[idx].num)
            }
        }
    }
    return {
        title: {
            text: '',
            subtext: ''
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: datatitle
        },
        toolbox: {
            show: true,
            feature: {
                dataView: { show: true, readOnly: false },
                magicType: { show: true, type: ['line', 'bar'] },
                restore: { show: true },
                saveAsImage: { show: true }
            }
        },
        calculable: true,
        xAxis: [
            {
                type: 'category',
                // prettier-ignore
                data: date
            }
        ],
        yAxis: [
            {
                type: 'value'
            }
        ],
        series: series
    }

}

